<template>
	<view class="ordermain" style="padding-top: 20px;">
		<div class="orderinfo" v-for="item in userOrderInfo" :key="item.id">
			<div>
				<div class="grid-content">
					订单编号：<span>{{ item.basic.id }}</span>
				</div>
			</div>
			<div>
				<div class="grid-content">
					下单人：<span>{{ item.basic.belong }}</span>
				</div>
			</div>
			<div>
				<div class="grid-content">
					下单时间：<span>{{ item.basic.time }}</span>
				</div>
			</div>
			<div>
				<div class="grid-content">
					车位所在小区：<span>{{ item.locationInfo.name }}</span>
				</div>
			</div>
			<div>
				<div class="grid-content">
					车位编号：<span>{{ item.basic.number }}</span>
				</div>
			</div>
			<div>
				<div class="grid-content">
					订单状态：<span>{{ orderStatus(item.basic.status) }}</span>
				</div>
			</div>
			<div>
				<div class="grid-content">
					销售公司：<span>{{ item.companyInfo.name }}</span>
				</div>
			</div>
			<div>
				<div class="grid-content">
					订单总金额：<span>{{ item.basic.price }}￥</span>
				</div>
			</div>
			<div>
				<div class="grid-content">
					<span class="topay"  @click="()=>topays(item.basic.id)" v-if="item.basic.status == 2">支付尾款</span>
				</div>
			</div>
		</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userOrderInfo: [{
					"basic": {
						"id": 1006,
						"address": 5,
						"belong": "111111",
						"number": 7,
						"time": "2020",
						"status": -1,
						"seller": 7,
						"price": 15000
					},
					"locationInfo": {
						"id": 5,
						"address": "BB",
						"belong": 6,
						"name": "BS"
					},
					"companyInfo": {
						"id": 7,
						"about": "CC",
						"type": 2,
						"name": "C",
						"phone": "CCC",
						"email": "CCCC"
					}
				}, {
					"basic": {
						"id": 1012,
						"address": 5,
						"belong": "111111",
						"number": 14,
						"time": "2021/8/30 15:53:17",
						"status": 0,
						"seller": 8,
						"price": 52000
					},
					"locationInfo": {
						"id": 5,
						"address": "BB",
						"belong": 6,
						"name": "BS"
					},
					"companyInfo": {
						"id": 8,
						"about": "DD",
						"type": 0,
						"name": "D",
						"phone": "DDD",
						"email": "DDDD"
					}
				}, {
					"basic": {
						"id": 1013,
						"address": 5,
						"belong": "111111",
						"number": 15,
						"time": "2021/8/30 16:0:34",
						"status": 2,
						"seller": 8,
						"price": 10000
					},
					"locationInfo": {
						"id": 5,
						"address": "BB",
						"belong": 6,
						"name": "BS"
					},
					"companyInfo": {
						"id": 8,
						"about": "DD",
						"type": 0,
						"name": "D",
						"phone": "DDD",
						"email": "DDDD"
					}
				}, {
					"basic": {
						"id": 1014,
						"address": 7,
						"belong": "111111",
						"number": 16,
						"time": "2021/8/30 17:6:7",
						"status": 1,
						"seller": 7,
						"price": 7000
					},
					"locationInfo": {
						"id": 7,
						"address": "永华路",
						"belong": 8,
						"name": "幸福小区"
					},
					"companyInfo": {
						"id": 7,
						"about": "CC",
						"type": 2,
						"name": "C",
						"phone": "CCC",
						"email": "CCCC"
					}
				}, {
					"basic": {
						"id": 1023,
						"address": 7,
						"belong": "111111",
						"number": 16,
						"time": "2021/9/2 16:50:21",
						"status": 2,
						"seller": 7,
						"price": 15000
					},
					"locationInfo": {
						"id": 7,
						"address": "永华路",
						"belong": 8,
						"name": "幸福小区"
					},
					"companyInfo": {
						"id": 7,
						"about": "CC",
						"type": 2,
						"name": "C",
						"phone": "CCC",
						"email": "CCCC"
					}
				}]
			}
		},
		onLoad() {

		},
		methods: {
			topays(e) {
				uni.showToast({
				    title: '支付中！',
					icon:'loading',
				    durati1on: 1000
				});
				setTimeout(()=> {
					for (var i = 0; i < this.userOrderInfo.length; i++) {
						if(this.userOrderInfo[i].basic.id == e) {
							this.userOrderInfo[i].basic.status = 1
						}
					}
					
					uni.showToast({
					    title: '默认使用优惠券支付支付成功！',
						icon:'none',
					    durati1on: 1000
					});
				},1000)
				
			},
			orderStatus(status) {
				if (status == 1) {
					return "交易成功";
				} else if (status == -1) {
					return "交易失败";
				} else if (status == 0) {
					return "审核中";
				} else if (status == 2) {
					return "摇号成功";
				} else {
					return "未知";
				}
			},
		}
	}
</script>

<style lang="scss" scope>
	.ordermain {
		padding: 0 50px;

		.orderinfo {
			border: 2px solid #bbb;
			border-radius: 15px;
			padding: 15px 20px;
			margin-bottom: 15px;
			box-shadow: 3px 3px 9px #999;
		}

		.topay {
			display: block;
			cursor: pointer;
			text-align: right;
			color: chocolate;
			font-size: 18px;
			margin: 0 auto;
		}
	}
</style>
